package highTech.Thread.threadLocal;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class ThreadScopeShareData {

	//private static int data=0;
	private static Map<String, Integer> threadData=new HashMap<String, Integer>();
	public static void main(String[] args) {
		for(int i=0;i<2;i++){
			new Thread(new Runnable() {
				
				@Override
				public void run() {
					int data=new Random().nextInt();
					System.out.println(Thread.currentThread().getName()+" has put data "+data);
					threadData.put(Thread.currentThread().getName(), data);
					new A().get();
					new B().get();
				}
			}).start();
		}

	}
	
	static class A{
		public void get(){
			System.out.println("A"+Thread.currentThread().getName()+" has get data "+threadData.get(Thread.currentThread().getName()));
		}
	}
	
	static class B{
		public void get(){
			System.out.println("B"+Thread.currentThread().getName()+"has get data "+threadData.get(Thread.currentThread().getName()));
		}
	}

}
